<?php $this->load->view('layout/header'); ?>

<div class="grid_10" id="content_wrapper">

    <div class="section_wrapper">

        <h3 class="title_black"><?php echo __('invoice'); ?></h3>

        <div class="content toggle">

            <div class="content toggle">

                <div id="tabs">
                    <!--tab link-->
                    <ul>
                        <li><a href="#tab_general"><?php echo __('customer'); ?></a></li>
                        <li><a href="#tab_detail"><?php echo __('detail'); ?></a></li>
                    </ul>
                    <!--/tab link-->

                    <!--General-->
                    <div id="tab_general">
                        <dl>
                            <dt><?php echo __('account_fullname'); ?></dt>
                            <dd style="font: bold;" ><?php echo $account->fullname; ?></dd>
                        </dl>
                        <dl>
                            <dt><?php echo __('email'); ?></dt>
                            <dd style="font: bold;" ><?php echo mailto($account->email); ?></dd>
                        </dl>
                        <dl>
                            <dt>Invoice ID</dt>
                            <dd style="font: bold;" ><?php echo $invoice->id; ?></dd>
                        </dl>
                        <dl>
                            <dt>Date</dt>
                            <dd style="font: bold;" ><?php echo $invoice->invoice_date; ?></dd>
                        </dl>
                        <dl>
                            <dt><?php echo __('total_amount'); ?>:</dt>
                            <dd style="font: bold;" ><?php echo format_currency($invoice->amount); ?></dd>
                        </dl>

                        <div style="clear: both;">&nbsp;</div>
                    </div>
                    <!--/General--> 

                    <!--Image-->
                    <div id="tab_detail">
                        <table style="width: 100%;">
                            <tr>
                                <th scope="col"><?php echo __('no.'); ?></th>
                                <th scope="col"><?php echo __('ticket'); ?></th>
                                <th scope="col"><?php echo __('price'); ?></th>
                                <th scope="col"><?php echo __('quantity'); ?></th>
                            </tr>
                            <?php
                            $total_amount = 0;
                            foreach ($invoice_detail as $index => $detail):;
                                $i = $index + 1;
                                $total_amount = $total_amount + $ticket_price[$detail->ticket_id] * $detail->quantity;
                                ?>
                                <tr class="hoverall">
                                    <td><?php echo $i; ?></td>
                                    <td><?php echo $ticket[$detail->ticket_id]; ?></td>
                                    <td><?php echo $detail->quantity; ?></td>
                                    <td><?php echo format_currency($ticket_price[$detail->ticket_id]); ?></td>
                                </tr>
                            <?php endforeach; ?>
                            <tr>
                                <td colspan="4" style="text-align: right"><?php echo __('total_amount'); ?>: <?php echo format_currency($total_amount); ?></td>
                            </tr>
                        </table>
                        <div style="clear: both;">&nbsp;</div>
                    </div>

                    <?php echo anchor('invoice-admin', __('back')); ?>
                    <div style="clear: both;">&nbsp;</div>
                </div>                

            </div>


            <!--            ********-->

        </div>       
    </div>

</div>

<!--        edit or delete by submit this form below-->
<?php
//echo form_open('', array('id' => 'invoice_list_form'), array('invoice_id' => 0, 'IS_FROM_LIST' => true));
//echo form_close();
?>
<!--        edit or delete by submit this form below-->
<script>
    $(function(){
        $('#tabs').tabs({ selected: <?php echo isset($tab_index) ? $tab_index : 0; ?> });
    });
    
    //function submit_invoice(id, action)
    //{
    //    $('input[name=invoice_id]').val(id);
    //    
    //    if (action=='delete')
    //        if ( !confirm('<?php //echo __('delete_comfirmation_message');    ?>'))
    //    return;
    //    
    //    $('#invoice_list_form').attr('action', '/invoice-admin/' + action);
    //    $('#invoice_list_form').submit();
    //}
    
</script>



<?php $this->load->view('layout/footer'); ?>
